import Vue from "vue";
import VueRouter from "vue-router";

//注册
Vue.use(VueRouter);
//定义路由规则
let routes = [
    {
        path: "/login",
        component: () => import("@/views/login.vue")
    },
    {
        path: "/index",
        component: () => import("@/views/index.vue"),
        children: [  //配置二级路由
            {
                path: "/index/home",
                component: () => import("@/views/home.vue")
            },
            {
                path: "/index/articleList",
                component: () => import("@/views/articleList.vue")
            },
            {
                path: "/index/addArticle",
                component: () => import("@/views/addArticle.vue")
            },
            {
                path: "/index/category",
                component: () => import("@/views/category.vue")
            }
        ]
    }
]

//生成路由对象
let router = new VueRouter({
    routes,
})

//导出
export default router